<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>公告管理</title>
    <link href="<?= BASE_URL ?>src/assets/css/bootstrap_5.3.2.min.css" rel="stylesheet">
    <link rel="stylesheet" href="<?= BASE_URL ?>src/assets/css/style.css">
    <!-- Bootstrap Icons -->
<!--    <link rel="stylesheet" href="--><?php //= BASE_URL ?><!--src/assets/css/bootstrap-icons.min.css">-->
</head>
<body class="bg-light">
<!-- 侧边栏 -->
<div class="sidebar">
    <a href="<?= BASE_URL ?>index.php" class="active">系统首页</a>
    <a href="<?= BASE_URL ?>index.php?c=department&a=index">科室信息</a>
    <a href="<?= BASE_URL ?>index.php?c=notice&a=index">公告管理</a>
    <a href="<?= BASE_URL ?>index.php?c=schedule&a=index">医生排班</a>
    <a href="<?= BASE_URL ?>index.php?c=manager&a=index">管理员信息</a>
    <a href="<?= BASE_URL ?>index.php?c=statistics&a=index">统计报表</a>
</div>
<div class="container mt-5">
    <div class="card shadow">
        <div class="card-header bg-primary text-white">
            <div class="d-flex justify-content-between align-items-center">
                <h3 class="mb-0">公告管理</h3>
                <a href="<?= BASE_URL ?>index.php?c=notice&a=add" class="btn btn-light btn-sm">
                    <i class="bi bi-plus-lg"></i> 新增公告
                </a>
            </div>
        </div>

        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover align-middle">
                    <thead class="table-light">
                    <tr>
                        <th scope="col" class="w-50">标题</th>
                        <th scope="col">发布时间</th>
                        <th scope="col" class="text-end">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($notices as $notice): ?>
                        <tr>
                            <td class="fw-bold"><?= htmlspecialchars($notice['title']) ?></td>
                            <td>
                                    <span class="badge bg-secondary">
                                        <?= date('Y-m-d H:i', strtotime($notice['created_at'])) ?>
                                    </span>
                            </td>
                            <td class="text-end">
                                <div class="btn-group" role="group">
                                    <a href="<?= BASE_URL ?>index.php?c=notice&a=edit&id=<?= $notice['id'] ?>"
                                       class="btn btn-outline-primary btn-sm">
                                        <i class="bi bi-pencil"></i> 编辑
                                    </a>
                                    <a href="<?= BASE_URL ?>index.php?c=notice&a=delete&id=<?= $notice['id'] ?>"
                                       class="btn btn-outline-danger btn-sm"
                                       onclick="return confirm('确定要删除这条公告吗？')">
                                        <i class="bi bi-trash"></i> 删除
                                    </a>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
            </div>

            <?php if (empty($notices)): ?>
                <div class="alert alert-info text-center mb-0">
                    <i class="bi bi-info-circle"></i> 当前没有公告信息
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

<!-- Bootstrap JS -->
<script src="<?= BASE_URL?><?= BASE_URL ?>src/assets/js/bootstrap.bundle.min.js"></script>

</body>
</html>